﻿/*
 * 名称：程序设计语言-编译原理算法
 * 制作者：WT
 * 创建时间：2012-10-15
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace CompilerDLL.SyntaxAnalysis
{
    [Serializable]

    public class SyntaxTreeNode:ICloneable 
    {
        private SyntaxTreeNode parentNode;
        /// <summary>
        /// 记录父节点，如果父节点为空时，则为根
        /// </summary>
        public SyntaxTreeNode ParentNode
        {
            get { return parentNode; }
            set { parentNode = value; }
        }

        ArrayList childNodes = new ArrayList();
        /// <summary>
        /// 当前节点的子节点，元素为SyntaxTreeNode类型
        /// </summary>
        public ArrayList ChildNodes
        {
            get { return childNodes; }
            set { childNodes = value; }
        }

        private int level = 0;

        /// <summary>
        /// 当前节点所处的层次
        /// </summary>
        public int Level
        {
            get { return level; }
            set { level = value; }
        }

        private string nodeSymbol = "";

        /// <summary>
        /// 当前节点所标记的符号
        /// </summary>
        public string NodeSymbol
        {
            get { return nodeSymbol; }
            set { nodeSymbol = value; }
        }


        private int intCurrentStep;

        /// <summary>
        /// 记录当前的执行步
        /// </summary>
        public int IntCurrentStep
        {
            get { return intCurrentStep; }
            set { intCurrentStep = value; }
        }

        /// <summary>
        /// 深度Clone();
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            
            System.Runtime.Serialization.Formatters.Binary .BinaryFormatter Formatter =
                new System.Runtime.Serialization.Formatters.Binary .BinaryFormatter(
                    null, 
                    new System.Runtime.Serialization .StreamingContext(System.Runtime.Serialization .StreamingContextStates.Clone));
            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            Formatter.Serialize(stream, this);
            stream.Position = 0;
            object clonedObj = Formatter.Deserialize(stream);
            stream.Close();
            return clonedObj; 


        }

    }
}
